#! /bin/bash
DB_HOST="127.0.0.1"
DB_NANE="testdatabase"
DB_USER="root"
DB_PASS=""
DATE=`date +%Y%m%d%h%m%s`
MYSQL_PATH=/root/
back_up(){
    BAKUP_FILE=${MYSQL_PATH}${DB_NAME}${DATE}.sql
    SQL_OPT="-u${DB_USER} -p${DB_PASS} -h${DB_HOST} ${DB_NAME}"
    mysqldump ${SQL_OPT} > ${BAKUP_FILE}
    if [ $? -eq 0 ];then
        echo 'ok';
    else
        echo 'error';
    fi
}
back_up;

蒙奇D颖
74 声望11 粉丝

成为海贼王